package com.hibegin.ftp;

import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;

public class StatusMap {

    private static Map<Integer, Method> map = new HashMap<Integer, Method>();

    static {
        reloadMap();
    }

    private static void reloadMap() {
        try {
            map.put(220, FtpResponseImpl.class.getMethod("connectSucc",
                    String.class));
            map.put(331, FtpResponseImpl.class.getMethod("inputPassword",
                    String.class));
            map.put(230,
                    FtpResponseImpl.class.getMethod("loginSucc", String.class));
            map.put(200, FtpResponseImpl.class.getMethod("initCmdSucc",
                    String.class));
            map.put(215, FtpResponseImpl.class.getMethod("modelChanageSucc",
                    String.class));
            map.put(227, FtpResponseImpl.class.getMethod("passiveModeSucc",
                    String.class));
            map.put(150,
                    FtpResponseImpl.class.getMethod("tipsMsg", String.class));
            map.put(226, FtpResponseImpl.class.getMethod("modelChanageSucc",
                    String.class));
            map.put(250, FtpResponseImpl.class.getMethod("initCmdSucc",
                    String.class));
            map.put(550,
                    FtpResponseImpl.class.getMethod("tipsMsg", String.class));
            map.put(500,
                    FtpResponseImpl.class.getMethod("tipsMsg", String.class));
            map.put(425,
                    FtpResponseImpl.class.getMethod("tipsMsg", String.class));
            map.put(530,
                    FtpResponseImpl.class.getMethod("loginFailed", String.class));

        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (SecurityException e) {
            e.printStackTrace();
        }
    }

    public static Method getMethod(Integer statusCode) {
        // just for dev
        reloadMap();
        return map.get(statusCode);
    }
}
